home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2865 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: news.shentel.net!Global-PPP
  2. From: scicom@globalcom.net (stephen j beaver)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Basic Question on SWITCH
  5. Date: Wed, 24 Jan 96 16:16:18 GMT
  6. Organization: scicom research us inc
  7. Distribution: world
  8. Message-ID: <4e5mc5$6oq@head.globalcom.net>
  9. References: <4e4cu4$95f@vixen.cso.uiuc.edu>
  10. NNTP-Posting-Host: eb3ppp13.shentel.net
  11. X-Newsreader: News Xpress Version 1.0 Beta #2
  12.  
  13. HOTARD <jhotard> wrote:
  14. >I am just learning how to program in C, and I had a question about switch.
  15. >I am writing a program that looks at a character and then determines if it is a
  16. >letter or number.  This program must use the switch command , can I place a
  17. >range on the case command somehow??
  18. >
  19. >ie:  Switch (var)
  20. >    case 0-9:
  21. >
  22. >or case (isdigit):
  23. >
  24. >would anything like this work???
  25. >
  26. >Thanks in advance
  27. >
  28. >Justin
  29. >
  30. The usual method would be:
  31.  
  32. switch(var)
  33.    {
  34.    case  0 :
  35.    case  1 :
  36.    case  2 :
  37.    case  3 :
  38.    case  4 :
  39.    case  5 :  do_stuff();
  40.                   some_more();
  41.                   break;
  42.    default  :
  43.    }
  44.  
  45. steve
  46.  
  47.